#include<bits/stdc++.h>
using namespace std;

int main()
{
	int n, la, lb, lc, ra, rb, rc;
	cin>>n;
	while(n--)
	{
		int ans = 0;
		cin>>la>>ra>>lb>>rb>>lc>>rc;
		for(int i = la;i <= ra;i++)
			for(int j = lb;j <= rb;j++)
				for(int k = lc;k <= rc;k++)
					if(i+j > k && i+k > j && j+k > i)
						ans++;
		cout<<ans<<endl;
	}
	return 0;
}

